package com.javasm.utils;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @className: RandomUtil
 * @description
 * @author: gfs
 * @date: 2024/7/16 15:07
 * @version: 0.1
 * @since : jdk11
 */
public class RandomUtil {
    //获取指定长度的 随机数字 6666  0123
    public static String getCode(int length) {
        if (length < 0) {
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (int i=0;i<length;i++){
            int num = ThreadLocalRandom.current().nextInt(0,10);
            stringBuilder.append(num);
        }
        return stringBuilder.toString();
    }
}
